package it.truestoryfactory.tsq.services.msg;

public abstract  class TSMessage {
	
	public static final String START_TAG = "tsmessage";
	public static final String TYPE_ATTRIBUTE = "type";
	
	public static TSMessage newTSMessage (String type) {
		if (type.equals(JoinMessage.TYPE))
			return new JoinMessage();
		else if (type.equals(SetupMessage.TYPE))
			return new SetupMessage();
		else if (type.equals(AnswerMessage.TYPE))
			return new AnswerMessage();
		return null;
	}
	public abstract String toXML();
	
	protected String startMessageTag(String type){
		return "<tsmessage type=\""+type+"\">";
	}
	
	protected String endMessageTag() {
		return "</tsmessage>";
	}

}
